﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;
namespace SimpleClient
{
    class Bullet
    {
        public bool hit;
        private int direction;
        private Point position;
        private int owner;
        public Bullet(int owner)
        {
            this.owner = owner;
            this.hit = false;
        }
        public int Direct //Direct属性(子弹行进方向）
        {
            get { return direction; }
            set { direction = value; }
        }
        public Point P
        {
            get { return position; }
            set {  position = value; }
        }
        public int Own
        {
            get{return owner;}
            set{owner = value;}
        }
        public void move()
        {
            switch (Direct)
            {
                case 0:
                    position.Y++;
                    break;
                case 1:
                    position.Y--;
                    break;
                case 2:
                    position.X++;
                    break;
                case 3:
                    position.X--;
                    break;
                default:
                    break;
            }
            foreach (Home h in Floor.hList)
            {
                int zx = 2 * System.Math.Abs(position.X - h.Position.X);
                int zy = 2 * System.Math.Abs(position.Y - h.Position.Y);
                int disx = 20;
                int disy = 20;
                if (zx < disx && zy < disy)
                {
                    hit = true;
                }
            }
        }
        public void Display(Graphics g)
        {
            SolidBrush b = new SolidBrush(Color.Blue);
            g.FillEllipse(b, position.X, position.Y, 5, 5);
        }
        public void UpDate(Graphics g)
        {
            move();
            SolidBrush b = new SolidBrush(Color.Yellow);
            g.FillEllipse(b, position.X, position.Y, 5, 5);
        }
        public void UnDisplay(Graphics g)
        {

        }
        public bool hitE(int tanktype) //是否击中
        {
            if (owner != tanktype)
            {
                return true;
            }
            else
                return false;
        }
    }
}
